//package com.example.rocketmq.demo.config;
//
//import org.springframework.context.annotation.Configuration;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.apache.rocketmq.client.producer.DefaultMQProducer;
//import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
//import org.apache.rocketmq.client.exception.MQClientException;
//import org.springframework.context.annotation.Configuration;
//
//@Configuration
//public class RocketMQConfig {
//
//    @Value("${rocketmq.name-server}")
//    private String nameServer;
//
//    @Value("${rocketmq.producer.group}")
//    private String producerGroup;
//
//    /**
//     * 创建普通消息发送者实例
//     */
//    @Bean(name = "defaultMQProducer")
//    public DefaultMQProducer defaultProducer() throws MQClientException {
//        DefaultMQProducer producer = new DefaultMQProducer(producerGroup);
//        producer.setNamesrvAddr(nameServer);
//        producer.setVipChannelEnabled(false);
//        producer.setRetryTimesWhenSendAsyncFailed(3);
//        producer.setRetryTimesWhenSendFailed(3);
//        producer.setSendMsgTimeout(3000);
//        producer.start();
//        return producer;
//    }
//
//    /**
//     * 创建事务消息发送者实例
//     */
//    @Bean(name = "transactionProducer")
//    public DefaultMQProducer transactionProducer() throws MQClientException {
//        DefaultMQProducer producer = new DefaultMQProducer(producerGroup + "-tx");
//        producer.setNamesrvAddr(nameServer);
//        producer.setVipChannelEnabled(false);
//        producer.setRetryTimesWhenSendAsyncFailed(3);
//        producer.setRetryTimesWhenSendFailed(3);
//        producer.setSendMsgTimeout(3000);
//        producer.start();
//        return producer;
//    }
//}
